/*******************************************************************************
 * @brief: GUI
 * @Author:   aple
 * @Date: 2022-10-29 10:27:22
 * @LastEditors: aple
 * @LastEditTime: 2022-10-29 11:15:36
 * @Verision: 1.0.0.0
 ******************************************************************************/
#ifndef __GUI_MAIN_H
#define __GUI_MAIN_H

#include <stdint.h>
#include "dataproc.h"
#include "pulse.h"
#include "rtctime.h"
#include "mytype.h"
#include "iohandle.h"

#ifdef __cplusplus
extern "C"
{
#endif

#ifdef _GUI_MAIN_MODULE_
#define MY_EXT
#else
#define MY_EXT extern
#endif

#define GUI_PAGE_START 0
#define GUI_PAGE_TEXT 1
#define GUI_PAGE_MENU 2
#define GUI_PAGE_SET 3

#define KEY_VAL_SET 1
#define KEY_VAL_UP 2
#define KEY_VAL_DN 4
#define KEY_VAL_SHIFT 8

	typedef struct
	{
		int16_t page_now;
		int16_t page_old;
		volatile int16_t page_reg;

		int16_t text_index;

		uint16_t font_color;
		uint16_t update_time_cnt;
		uint16_t gui_cnt;

		uint32_t page_keep_time_cnt;

		key_type key;
		timer_pulse_type pulse;

		uint8_t start_bar_cnt;
		uint8_t img_lib_ok;
		uint8_t b_auto_sw;
		uint8_t notice_mode;
		char notice_str[130];

		uint8_t move_mode;
		uint8_t move_en;
		int16_t move_site_x;
		int16_t move_site_y;

		volatile uint8_t b_text_update_req;
		uint8_t menu_sel;

		uint16_t edit_shift;

		char buff[64];
	} gui_st_type;

	typedef struct
	{
		const char *en_code;
		const char *cn_code;
		uint16_t first_par_site;
		uint16_t password;
	} menu_opt_type;

	extern const menu_opt_type menu_list[];

	MY_EXT gui_st_type gui_st;

	void GuiPageText(void const *argument);
	void GuiPageStart(void const *argument);
	void GuiPageMenu(void const *argument);

	void gui_enter_menu(void const *argument);

	void gui_key_page_text(void const *argument);
	void gui_key_page_menu(void const *argument);
	void gui_key_page_set(void const *argument);

	void gui_notice(const char *);

#undef MY_EXT

#ifdef __cplusplus
}
#endif

#endif /* __GUI_MAIN_H */
